﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Wpftest.CommonClass;

namespace Wpftest.ControlFile
{
    /// <summary>
    /// CollectionBinding.xaml 的交互逻辑
    /// </summary>
    //集合数据绑定也是双向的
    public partial class CollectionBinding : UserControl
    {
        public CollectionBinding()
        {
            InitializeComponent();
            List<Student> liststu = new List<Student>();
            for (int i = 0; i < 12; i++)
            {
                var stu = new Student
                {
                    Name = string.Format("张三{0}", i),
                    Sex = i / 2 == 0 ? "Boy" : "Girl",
                    Age = i + 20
                };
                liststu.Add(stu);
            }
            this.DataContext = liststu;
        }
    }
}
